package image;
import com.google.appengine.api.images.Image;
import com.google.appengine.api.images.ImagesService;
import com.google.appengine.api.images.ImagesServiceFactory;
import com.google.appengine.api.images.Transform;
public class ResizeImage{
	public ResizeImage(){}
	public byte[] resizeImage(byte[] imagebytes, String width, String height){
		ImagesService imagesService = ImagesServiceFactory.getImagesService();
        Image oldImage = ImagesServiceFactory.makeImage(imagebytes);
        // Do the image resize.
        int width_int = Integer.parseInt(width);
        int height_int = Integer.parseInt(height);
        Transform resize = ImagesServiceFactory.makeResize(width_int, height_int);

        // Create a new image from changing image size.
        Image newImage = imagesService.applyTransform(resize, oldImage);
        byte[] newImageData = newImage.getImageData();
        return newImageData;
	}
}